home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac Mania 4
/
MacMania 4.toast
/
/
Demo's
/
Igor Demo Pro
/
3 PutContentsIn Igor Pro Folder
/
Technical Notes
/
Igor Tech Notes
/
TN033 Confidence Bands
/
Conf Bands TEXT
< prev
next >
Wrap
Text File
|
1993-05-07
|
2KB
|
85 lines
| Returns area of Student's distribution function from -t,t given v degrees of freedom
| Same as Abramowitz and Stegun, Page 990. Note that this includes both
| tails.
|
Function StudentA(t,v)
Variable t,v | Student's t, degreees of freedom v
return 1-betai(v/2, .5, v/(v+t^2))
End
| Returns that t that gives the A given v degrees of freedom
| Doesn't handle ridiculous values like 2 degrees of freedom and 0.99999
|
Function StudentT(A,v)
Variable A,v | A= probablility, v= degrees of freedom
if( (A>1) %| (A<0) %| (v<0) )
return NaN
endif
variable tl= 0, tu= 100 | lower and upper bounds
variable tm | midpoint
do
if( tu-tl <= 0.000005 ) | assume A to 5 sig figs is good enough
break;
endif
tm= (tu+tl)/2
if( StudentA(tm,v) < A )
tl= tm
else
tu= tm
endif
while(1)
return tl
end
Macro AddPredictionInterval(ydata,xdata,conf,kind)
String ydata,xdata
Variable conf=95,kind=1
Prompt ydata,"Y Data",popup WaveList("*",";","")
Prompt xdata,"X Data",popup "_calculated_;"+WaveList("*",";","")
Prompt conf,"confidence, %"
Prompt kind,"confidence kind",popup "Of the true mean;Of future measurements"
PauseUpdate; Silent 1
kind= kind==2
String pconf= ydata+"_PC", nconf= ydata+"_NC"
if( kind )
pconf += "D"; nconf += "D" | addition of D to suffex denotes conf of future data
endif
Duplicate $ydata,tmpxdata,tmpydata
if( CmpStr(xdata,"_calculated_") == 0 )
tmpxdata= x
else
tmpxdata= $xdata
endif
Make/O/N=100 $pconf,$nconf
WaveStats/Q tmpxdata
SetScale x,V_min,V_max,"",$pconf,$nconf
CheckDisplayed $pconf
if( !V_Flag )
Append $pconf,$nconf
endif
Variable XBar= V_Avg
tmpydata = (tmpydata- (K0+K1*tmpxdata))^2
WaveStats/Q tmpydata
Variable s2= V_Avg*V_npnts/(V_npnts-2)
KillWaves tmpydata
tmpxdata= (tmpxdata-XBar)^2
WaveStats/Q tmpxdata
Variable SSXM= V_Avg*V_npnts
KillWaves tmpxdata
Variable k= StudentT(conf/100,V_npnts-2)*sqrt(s2)
$pconf= k*sqrt(kind + 1/V_npnts + (x-XBar)^2/SSXM)
$nconf= K0+K1*x-$pconf
$pconf += K0 + K1*x
End